//
//  YSGNurseAppointmentModel.swift
//  EyeVisionForPatients
//
//  Created by liuyutian on 2022/3/21.
//  Copyright © 2022 QDSG. All rights reserved.
//

import HandyJSON

struct YSGNurseAppointmentModel: HandyJSON {
    var chargeItemType: Int?
    var chargeItemCode: String?
    var chargeItemName: String?
    var unit: String?
    var price: String?
    
}

struct YSGNurseAppointmentViewModel {
    
    var models: [YSGNurseAppointmentModel]
    
    var numberOfSections: Int { return models.count }
    
    /// 所有项目列表
    static func getProjectList(_ chargeItemType : String, finished: @escaping (_ models: [YSGNurseAppointmentModel], _ errorMsg: String?, _ code: HttpCode) -> Void) {
        

        HttpTool.shared.request(target: ApiManager.appointment_get_itemList(chargeItemType: chargeItemType), success: { (json, code) in
            if let models = JSONDeserializer<YSGNurseAppointmentModel>.deserializeModelArrayFrom(json: json["data"]["chargeItems"].description) as? [YSGNurseAppointmentModel] {
                finished(models, nil, .success)
            } else {
                finished([], json["message"].description, .failure)
            }
        }) { errorMsg in
            finished([], errorMsg, .failure)
        }
    }
    
    
}
